{extend name="base" /}
{block name="body"}
<div class="layui-card">
	<div class="layui-card-body">
        <div class="layui-btn-group">
		    <a href="{:url('user/index/sub_user_add')}" class="layui-btn"><i class="fa fa-plus-circle"></i> 添加子账户</a>
        </div>
		<table class="layui-table layui-form">
			<thead>
				<tr>
					<th lay-data="{field:'id',sort: true}">类型</th>
					<th lay-data="{field:'username'}">用户名</th>
					<th lay-data="{field:'mobile'}">手机号</th>
					<th lay-data="{field:'last_login_time',sort: true}">上次登录时间</th>
					<th lay-data="{field:'last_login_ip',sort: true}">上次登录IP</th>
					<th lay-data="{field:'login_count',sort: true}">登录次数</th>
					<th lay-data="{field:'create_time',sort: true}">创建时间</th>
					<th lay-data="{field:'status',sort: true}">状态</th>
					<th lay-data="{field:'setting'}">操作</th>
				</tr>
			</thead>
			<tbody>
				{foreach name="list" item="v" empty="$empty"}
                                <?php $shop = app\common\model\Shop::get($v['shop_id']);?>
				<tr>
					<td>
                                            {if $shop.admin_id == $v.id}
                                            <button class="layui-btn layui-btn-xs">主账号</button>
                                            {else}
                                            <button class="layui-btn layui-btn-xs layui-btn-warm">子账号</button>
                                            {/if}
                                        </td>
					<td>{$v.username}</td>
					<td>{$v.mobile}</td>
					<td>{if empty($v.last_login_time)}无{else/}{$v.last_login_time|date='Y-m-d H:i:s', ###}{/if}</td>
					<td>{$v.last_login_ip|default='无'}</td>
					<td>{$v.login_count}</td>
					<td>{$v.create_time}</td>
					<td>
                                            {if $shop.admin_id != $v.id}
						<input type="checkbox" name="status" lay-skin="switch" lay-filter="*" lay-text="启用|禁用" data-url="{:url('user/index/sub_user_edit', ['id' => $v.id])}" {if $v.status eq 1}checked="checked"{/if}>
                                            {/if}
					</td>
					<td>
                                            {if $shop.admin_id != $v.id}
						<a href="{:url('user/index/sub_user_edit', ['id' => $v.id])}" class="layui-btn layui-btn-xs layui-btn-normal"><i class="fa fa-edit"></i> 编辑</a>
						<a href="{:url('user/index/sub_user_del', ['id' => $v.id])}" class="layui-btn layui-btn-xs layui-btn-danger ajax-delete"><i class="fa fa-trash-o"></i> 删除</a>
                                            {/if}
					</td>
				</tr>
				{/foreach}
			</tbody>
		</table>
		<div class="page">{$list->render()}</div>
	</div>
</div>
{/block}